import { ElMessage, ElMessageBox } from 'element-plus'

export function deleteBox(delApi, params, t) {
  if (!delApi) {
    console.warn('delApi is undefined')
    return
  }
  return ElMessageBox.confirm(t('common.delMessage'), t('common.delWarning'), {
    confirmButtonText: t('common.delOk'),
    cancelButtonText: t('common.delCancel'),
    type: 'warning'
  }).then(async () => {
    const res = await delApi(params)
    if (res) {
      ElMessage.success(t('common.delSuccess'))
      return res
    }
  })
}
